home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_item_shields_m.cog < prev    next >
Text File  |  1998-02-25  |  3KB  |  150 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # ITEM_SHIELDS_M.COG
  4. #
  5. # ITEM Script - Shields
  6. #  Bin 60
  7. #
  8. # [YB]
  9. #
  10. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  11.  
  12.  
  13. symbols
  14.  
  15. thing            player
  16.  
  17. flex            shields
  18. flex            shieldsLeft
  19. flex            damage
  20. flex            halfdamage
  21. flex            type
  22.  
  23. sound            hitsnd=KShieldHit01.wav
  24.  
  25. message        damaged
  26.  
  27. end
  28.  
  29. # ========================================================================================
  30.  
  31. code
  32.  
  33. damaged:
  34.     player = GetSenderRef();
  35.     shields = GetInv(player, 60);
  36.     damage = GetParam(0);
  37.     halfdamage = 0;
  38.     
  39.     if(shields > 0)
  40.     {
  41.         type = GetParam(1);
  42.         shieldsLeft = shields;
  43.  
  44.         // If damage from energy or fire.
  45.         if((type == 2) || (type == 4))
  46.             halfdamage = damage;
  47.         else
  48.         if(type == 16)
  49.             halfdamage = damage / 2;
  50.  
  51.         if ((halfdamage > 0.0) && shieldsLeft)
  52.         {
  53.             AddDynamicTint(player, 0, damage/50, 0);
  54.             PlaySoundThing(hitsnd, player, 1.0, -1, -1, 128);
  55.     
  56.             if (shields > 50)
  57.             {
  58.                 shieldsLeft = shields - 50;
  59.  
  60.                 if (shieldsLeft > halfdamage)
  61.                     shieldsLeft = halfDamage;
  62.  
  63.                 damage = damage - shieldsLeft;
  64.                 halfdamage = halfDamage - shieldsLeft;
  65.                 shields = shields - shieldsLeft;
  66.             }
  67.  
  68.             if (halfDamage > 0.0)
  69.             {
  70.                 halfDamage = halfDamage / 2;
  71.  
  72.                 shieldsLeft = shields;
  73.  
  74.                 if (shieldsLeft > halfdamage)
  75.                     shieldsLeft = halfDamage;
  76.  
  77.                 damage = damage - shieldsLeft;
  78.                 halfdamage = halfDamage - shieldsLeft;
  79.                 shields = shields - shieldsLeft;
  80.             }
  81.         }
  82.  
  83. //        if((type == 2) || (type == 4))
  84. //        {
  85. //            AddDynamicTint(player, 0, damage/50, 0);
  86. //            PlaySoundThing(hitsnd, player, 1.0, -1, -1, 128);
  87. //    
  88. //            // Shields do full protection until they are at 50 or less.
  89. //            shieldsLeft = shields - damage;
  90. //            if(shieldsLeft > 50)
  91. //            {
  92. //                damage = 0;
  93. //            }
  94. //            else
  95. //                if(shields > 50)
  96. //            {
  97. //                damage = damage - (shields - 50);
  98. //            }
  99. //    
  100. //            // Scale what damage is left by shields.
  101. //            if(damage > 0)
  102. //            {
  103. //                damage = damage * (1 - shieldsLeft / 50);
  104. //            }
  105.     
  106.             // Inventory system will minimize shields at 0.
  107.             SetInv(player, 60, shields);
  108. //        }
  109. //
  110. //        // If damage from saber.
  111. //        if(type == 16)
  112. //        {
  113. //            AddDynamicTint(player, 0, damage/50, 0);
  114. //         PlaySoundThing(hitsnd, player, 1.0, -1, -1, 0);
  115. //    
  116. //         // Shields do half protection
  117. //            halfdamage = damage / 2;
  118. //            damage     = halfdamage;
  119. //            
  120. //            shieldsLeft = shields - damage;
  121. //            if(shieldsLeft > 50)
  122. //            {
  123. //                damage = 0;
  124. //            }
  125. //            else
  126. //                if(shields > 50)
  127. //            {
  128. //                damage = damage - (shields - 50);
  129. //            }
  130. //    
  131. //            // Scale what damage is left by shields.
  132. //            if(damage > 0)
  133. //            {
  134. //                damage = damage * (1 - shieldsLeft / 50);
  135. //            }
  136. //    
  137. //            // Inventory system will minimize shields at 0.
  138. //            SetInv(player, 60, shieldsLeft);
  139. //
  140. //            // add the original half damage back
  141. //            damage = damage + halfdamage;
  142. //        }
  143.     }
  144.  
  145.     ReturnEx(damage);
  146.     Return;
  147.  
  148. end
  149.  
  150.